<?php
/************************************
*   熊店
*   @file:/server/bearshop/page/p_img.php
*   @intro:
*   @author:new_shop
*   @email:new_shop@163.com    
*   @date:Thu Feb 18 21:20:01 CST 2010
************************************/

class p_img extends page_controllor 
{
    public function __construct($get_param)
    {
        $this->__need_session = false;
        $this->__need_login = false;
        
        parent::__construct($get_param);
    }
    
    public function run()
    {
        $id = (int)$this->get_input(0);
        if($id < 1)
            die();
            
        $is_sketch = $this->get_input(1) == 'sk' ? true : false;
        $is_temp = $this->get_input(2) == 't' ? true : false;
        
        if($is_temp)
        {
            $dir = K5_UPLOAD_PATH.'/temp/';
        }
        else 
        {
            $hash_n = ceil($id / 100);
            $dir = K5_UPLOAD_PATH.'/design/'.$hash_n.'/';
        }
        
        $filename = 'design_'.$id.($is_sketch ? '_sk' : '');
        
        $filepath = $dir.$filename;
        $info = getimagesize($filepath);
        
        header("Content-Type: ".$info['mime']);
        header("Content-Length: " . filesize($filepath));
        
        $fp = fopen($filepath , 'rb');
            
        fpassthru($fp);
        exit;
    }
}
?>